package com.dgut.cbd.finalexp.dao;

import com.dgut.cbd.finalexp.dto.RecordInfo;
import com.dgut.cbd.finalexp.entity.Record;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface RecordDao {

    @Select("select * from record where date=#{dateString} and stu_id=#{stuId} limit 1")
    public Record getOneRecordByDateAndId(Record record);


    @Insert("insert into record (stu_id,phone,health,danger_people_contact,temperature," +
            "date,emergency_contact_phone,emergency_contact_name,danger_area_reach," +
            "danger_mark,now_location" +
            ") value(#{stuId},#{phone},#{health},#{dangerPeopleContact},#{temperature}," +
            "#{date},#{emergencyContactPhone},#{emergencyContactName},#{dangerAreaReach}," +
            "#{dangerMark},#{nowLocation})")
    public boolean insertRecord(Record record);


    @Select("select * from record")
    public List<Record> getAllRecord();

    List<Record> selectRecordsByRegisterInfo(RecordInfo recordInfo);
}
